package codeRandomThoughts.Test700二叉搜索书中的搜索;

import codeRandomThoughts.utils.TreeNode;

public class Solution {
    public TreeNode searchBST(TreeNode root, int val) {
        TreeNode node = root;
        while (node != null) {
            if (val > node.val) {
                node = node.right;
            } else if (val < node.val) {
                node = node.left;
            }else {
                return node;
            }
        }
        return null;
    }
}
